﻿using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;

namespace Dino.EntityFramework
{
    public static class ObjectContextExtensions
    {
        public static IEnumerable<T> Execute<T>(this IObjectContext context, string name, params string[] parameters)
        {
            var dbContext = context as DbContext;

            if (dbContext != null)
            {
                return dbContext.Database.SqlQuery<T>(name);
            }

            return Enumerable.Empty<T>();
        }
    }
}